/*
 * testAnalyser.cc
 *
 *  Created on: Dec 7, 2012
 *      Author: hxin
 */

#include "analyser.h"
#include "common.h"
#include <sstream>
#include <string>
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

int main(int argc, char* argv[]) {

	if (argc != 2) {
		cerr << "bin chrNum" << endl;
		return -1;
	}

	int chrNum = atoi(argv[1]);

	stringstream picFileStream;

	string picFileName;

	int maxUnitColor = 0;

	int readLength[3] = { 72, 108, 144 };

	while (1) {

		analyser_config = FAKE_ALIGN_HET;

		for (int i = 9; i <= 15; i++) {
			cerr << "KmerSize: " << i << endl;
			cout << "KmerSize: " << i << endl;

			cout << endl << "[" << i << "]" << endl;

			for (int j = 5; j >= 5; j--) {

				analyser analyser_obj("human_g1k_v37.fasta", i, j);
				cout << "Error: " << j << endl;
				cerr << "Error: " << j << endl;

				for (int k = 0; k < 3; k++) {

					if (i * (j + 1) <= readLength[k]) {

						cout << "ReadLength: " << readLength[k] << endl;
						cerr << "ReadLength: " << readLength[k] << endl;

						analyser_obj.unloadHash();

						picFileStream.clear();

						if (analyser_config == FAKE_ALIGN_HET)
							picFileStream << "./Pics/chr_het_";
						else
							picFileStream << "./Pics/chr";

						picFileStream << chrNum << "_" << i
								<< "_" << readLength[k] << "_" << j << ".ppm";
						picFileStream >> picFileName;

						analyser_obj.sweepChromosome(chrNum, readLength[k]);

						maxUnitColor = analyser_obj.genStat(maxUnitColor);
						cerr << "picFileName: " << picFileName << endl;
						//analyser_obj.printPic(picFileName, maxUnitColor);

						analyser_obj.printStat();
						analyser_obj.printPic(picFileName, maxUnitColor);

					}

				}

			}
		}

		if (analyser_config == FAKE_ALIGN_HET)
			break;

		analyser_config = FAKE_ALIGN_HET;

	}

	return 0;
}

